layui.define(['form'], function(exports){
  var $ = layui.$,form = layui.form;

  var userId = $('input[name="id"]').val();

    //事件
    var active = {
        transferMoney:function (accountGroupId){
            layer.open({
                type: 2
                , title: '转出金额至提现'
                , content: layui.setter.webRoot + '/team/user/wallet/withdrawal_money/transfer.html?userId='+userId+'&accountGroupId='+accountGroupId
                , maxmin: true
                , area: ['500px', '400px']
                ,btn: ['确定', '取消']
                , yes: function(index, layero){
                    var iframeWindow = window['layui-layer-iframe'+ index]
                        ,submitID = 'LAY-form-submit'
                        ,submit = layero.find('iframe').contents().find('#'+ submitID);
                    iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                        var field = data.field;
                        $.ajax({
                            type: "post",
                            url: layui.setter.webRoot + '/team/user/wallet/withdrawal_money/transfer.do',
                            data:field,
                            dataType:"json",
                            success:function(res){
                                if(res.code == 200){
                                    layer.msg('转出成功',{icon: 1});
                                    location.reload();
                                }else{
                                    layer.msg(res.msg,{icon: 2});
                                }
                            }
                        });
                    });
                    submit.trigger('click');
                }
            })
        }
        ,operateRecord:function (accountGroupId){
            parent.layer.open({
                type: 2
                , title: '钱包流水列表'
                , content: layui.setter.webRoot + '/team/user/wallet/operate/list.html?userId='+userId+'&accountGroupId='+accountGroupId
                , maxmin: true
                , area: ['90%', '90%']
                , btn: ['取消']
            })
        }
    }

    $('.layui-btn.LAY-btn-fun').on('click', function(){
        var type = $(this).data('type');
        var accountGroupId = $(this).data('id');
        active[type] ? active[type].call(this,accountGroupId) : '';
    });

  exports('user_wallet_info', {})
});